//
//  PrivacyWebView.swift
//  KoiAccounting
//
//  Created by 纪洪文 on 18.03.25.
//

import SwiftUI
import WebKit

struct PrivacyWebView: View {
    @Environment(\.presentationMode) var presentationMode
    @State private var isLoading = true
    let title:String
    let url:String
    
    static var privacyView: some View {
        PrivacyWebView(title:"隐私政策", url:"https://www.koiaccounting.com/about/privacy.html")
    }
    
    static var termsView: some View {
        PrivacyWebView(title:"用户协议", url:"https://www.koiaccounting.com/about/terms.html")
    }
    
    var body: some View {
        VStack {
            HStack {
                Button(action: {
                    presentationMode.wrappedValue.dismiss()
                }) {
                    Image(systemName: "chevron.left")
                        .padding(5)
                        .foregroundColor(.black)
                }
                Spacer()
                Text(title).font(.system(size: 18))
                    .bold()
                    .font(.headline)
                    .foregroundColor(.black)
                Spacer()
                // Empty space for alignment purpose
                Image(systemName: "chevron.left")
                    .foregroundColor(.clear)
            }
            .padding()
            KoiWebView(url: url)
        }
    }
}

#Preview {
    PrivacyWebView(title:"隐私协议",url:"https://www.koiaccounting.com/about/privacy.html")
}
